package com.accenture.adf.newcodington.module6.sample;

/**
 * 
 * CityTour is about buying a travel pass which can be used to go around New Codington         
 * 
 *SeeIt 1:- Creation of a class
 * 
 * Instructions:
 * 1. Create a public class named 'CityTour_Demo1' with a main() method and print "Hello ADF Java Participants"
 * message to the console 
 * 
 *    
 *SeeIt 2:- Creating constants and variables of different data types
 * 
 * Instructions: 
 * 1. Declare a private static final float variable for basic ticket fare and initialize it between class declaration and main() method
 * 2. On the next line, declare a private static final float variable for service tax expressed as percentage and initialize it
 * 3. Create variables of different data types used in calculating the ticket fare for city tour inside main() method
 *    a. Declare an integer variable for number of tickets issued 
 *    b. Declare a double variable for total ticket fare
 * 
 *    
 *SeeIt 3:- Usage of basic arithmetic operators
 * 
 * Instructions: 
 * 1. Remove console output statement printing 'Hello ADF Java Participants'
 * 2. Initialize the variable for number of tickets issued (noOfTickets)
 * 3. Calculate total ticket fare by first multiplying service tax with base ticket fare 
 *    then multiply base ticket fare with number of tickets
 * 4. Print total ticket fare to the console
 * 
 * 
 *SeeIt 4:- Usage of If / Else structure
 * 
 * Instructions:  
 * 1. Declare a boolean variable for identifying weekday or weekend 
 *    a. Initialize variable weekday to true or false 
 * 2. Use If / Else to check for weekday and print appropriate message to the console
 *    a. If weekday, print 'Traveling on weekday, no additional charge applicable'
 *    b. If weekend, print 'Traveling on weekend, additional weekend charge applicable on each ticket'
 *    
 *    
 *SeeIt 5:- Usage of logical operators
 * 
 * Instructions:
 * 1. Declare a character variable to identify travel class
 *    a. Travel class could be economy (e), business (b) or first class (f)
 * 2. Initialize newly declared variable travel class
 * 3. Use If / Else to check for weekday & travel class and print appropriate message to the console
 *    a. weekday and economy class travel, print 'Traveling on weekday in economy class, no additional charge applicable'
 *    b. weekday and business or first class travel, print 'Traveling on weekday in non economy class, 
 *    	additional charge applicable on each ticket'
 *    c. travel class not in e, b or f, print 'Please choose 'e', 'b', of 'f' only for travel class' 
 *    d. otherwise, print 'Traveling on weekend, additional weekend charge applicable as per travel class'
 * 
 *    
 *SeeIt 6:- Usage of switch-case structure
 * 
 * Instructions: 
 * 1. Modify If / Else for checking only week day flag and print appropriate message to console
 * 		a. For weekday, print 'Traveling on weekday, no additional charge applicable'
 * 		b. For weekend, print 'Traveling on weekend, additional weekend charge applicable on each ticket'
 * 2. Use Switch-Case to check for travel class and print appropriate message to the console
 *    a. For economy class, print 'No additional charge for economy class'
 *    b. For business class, print 'Additional charge for business class applicable on each ticket'
 *    c. For first class, print 'Additional charge for first class applicable on each ticket'
 * 3. If travel class chosen is not in e, b or f then display message asking to choose one 
 *    among e, b or f only 
 * 
 *    
 *SeeIt 7:- Usage of for loop and while loop
 * 
 * Instructions:
 * 1. Use for loop to generate travel pass id with number of tickets issued as upper bound
 * 		a. Declare an integer variable for travel pass id
 * 		b. Travel pass id can be generated by simply incrementing the loop index by 1
 * 		c. Print travel pass id to the console along with loop index
 * 2. Declare a temporary index variable and initialize it to zero in main() method
 * 3. Use while loop to generate travel pass id with number of tickets issued as upper bound
 * 		a. Declare an integer variable for travel pass id
 * 		b. Travel pass id can be generated by simply incrementing the loop index by 1
 * 		c. Print travel pass id to the console along with loop index
 * 		d. Increase index by 1 for next iteration
 * 4. Comment out for loop to demonstrate while loop and vice versa
 * 
 * 
 *SeeIt 8:- Arrays and population of single dimensional array using for loop
 * 
 * Instructions:
 * 1. Declare an integer single dimensional array for travel pass sequence numbers inside main() method
 *    a. Initialize travel pass array with size as number of tickets
 * 2. Modify for loop to assign pass id's to travel pass array in respective indexes
 * 3. Modify while loop as a do..while loop with upper bound as travel pass array length
 * 		a. Remove pass id generation logic
 * 		b. Print array values along with array index to console
 * 
 * 
 *SeeIt 9:- Usage of methods, passing parameters and returning values.         
 * 
 * Instructions:
 * 1. Define a static method to calculate total fare based on weekday or weekend (weekday flag as parameter for the method)
 * 2. Specify return type for the new method as String
 * 3. Move If / Else logic to the new method
 * 4. Modify If condition to return the message to main() method instead of printing on console
 * 5. Modify Else condition to return the message to main() method instead of printing to console  
 * 6. Define a static method to calculate total fare based on travel class (travel class as the parameter for the method)
 * 7. Specify return type for the new method as String    
 * 8. Move Switch-Case logic to the new method
 * 9. Declare a String variable to capture return message from each of the choices
 * 10. Modify Case statements to set the return message to the string variable
 * 11. Return the message to main() method instead of printing to console
 * 12. Declare a string variable in the main() method to capture the return message from the each of the above methods
 * 13. Invoke method for weekend check and print the return message to console
 * 14. Invoke method for travel class check and print the return message to console  
 *    
 */

public class CityTour_Demo {
	
	private static final float BASE_FARE = 10; //Try with changing values
	private static final float SERVICE_TAX = 5; //Try with changing values
	
	public static void main(String[] args){
			
		int noOfTickets;		
		double totalFare;
		
		noOfTickets = 5; //Try with changing values
				
		totalFare = noOfTickets * (BASE_FARE * (1 + SERVICE_TAX / 100));
		
		System.out.println("Hello ADF Java Participants");
		System.out.println("Your Total Fare: "+totalFare);
		
		boolean weekDay;
		char travelClass;
		String result;		
		
		weekDay = true; //Try changing values true or false
		travelClass = 'f'; //Try changing values e, b or f
		
		result = checkIfWeekend(weekDay);
		System.out.println(result);
		
		result = checkTravelClass(travelClass);
		System.out.println(result);
		
		int[] travelPass = new int[noOfTickets];
		
		//Populate single dimensional array
		for(int i=0;i<noOfTickets;i++){
			int passID = i + 1;
			travelPass[i] = passID;	
		}
		
		//Print array values using do while
		int index = 0;
		do{
			System.out.println("\t" + (index) + ": " + travelPass[index]);
			index++;
		}while(index < travelPass.length);
	}
	
	/**
	 * Method checks for weekday or weekend and returns appropriate message to main() method 
	 * @param weekDay - flag for weekday or weekend
	 * @return - based on weekday flag method returns appropriate string message to main() method
	 */
	public static String checkIfWeekend(boolean weekDay){		
		if(weekDay){
			return "Traveling on weekday, no extra charge applicable";			
		}else{
			return "Traveling on weekend, extra weekend charge applicable on each ticket";
		}	
	}
	
	/**
	 * Method checks for travel class e, b or f and returns appropriate message to main() method
	 * @param travelClass - travel class could be e for economy, b for business and f for first class travel
	 * @return message - based on travel class chosen returns appropriate message to main() method 
	 */
	public static String checkTravelClass(char travelClass){	
		String message;
		
		switch(travelClass){
		
		case 'e': message = "No surcharge on economy class";
				  break;
		
		case 'b': message = "Business class surcharge applicable";				  
				  break;
		
		case 'f': message = "First class surcharge applicable";				  
				  break;
		
		default : message = "Please choose only 'e', 'b' or 'f' for travel class";
		}
		
		return message;
	}		
}
